
package com.yimixian.app.address;

import com.yimixian.app.model.Address;

import android.os.Parcel;
import android.os.Parcelable;

public class MutableAddress implements Parcelable {

    public final int id;
    public String name;
    public String gender;
    public String tel;
    public String address;
    public String provinceKey;
    public String province;
    public String cityKey;
    public String city;
    public String districtKey;
    public String district;
    public String poiId;
    public String poiName;
    public String poiAddress;
    public String roomNo;
    public String tag;
    public String longitude;
    public String latitude;
    public String coordSystem;
    public String storeId = "";
    public boolean isPickup;

    public MutableAddress() {
        id = 0;
    }

    public MutableAddress(Address address) {
        id = address.id;
        name = address.name;
        gender = address.gender;
        tel = address.tel;
        this.address = address.address;
        city = address.city;
        cityKey = address.cityKey;
        province = address.province;
        provinceKey = address.provinceKey;
        district = address.district;
        districtKey = address.districtKey;
        poiId = address.poiId;
        poiName = address.poiName;
        poiAddress = address.poiAddress;
        roomNo = address.roomNo;
        tag = address.tag;
        longitude = address.longitude;
        latitude = address.latitude;
        coordSystem = address.coordSystem;
        storeId = address.storeId;
        isPickup = address.isPickup;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.id);
        dest.writeString(this.name);
        dest.writeString(this.gender);
        dest.writeString(this.tel);
        dest.writeString(this.address);
        dest.writeString(this.provinceKey);
        dest.writeString(this.province);
        dest.writeString(this.cityKey);
        dest.writeString(this.city);
        dest.writeString(this.districtKey);
        dest.writeString(this.district);
        dest.writeString(this.poiId);
        dest.writeString(this.poiName);
        dest.writeString(this.poiAddress);
        dest.writeString(this.roomNo);
        dest.writeString(this.tag);
        dest.writeString(this.longitude);
        dest.writeString(this.latitude);
        dest.writeString(this.coordSystem);
        dest.writeString(this.storeId);
        dest.writeInt(this.isPickup ? 1 : 0);
    }

    protected MutableAddress(Parcel in) {
        this.id = in.readInt();
        this.name = in.readString();
        this.gender = in.readString();
        this.tel = in.readString();
        this.address = in.readString();
        this.provinceKey = in.readString();
        this.province = in.readString();
        this.cityKey = in.readString();
        this.city = in.readString();
        this.districtKey = in.readString();
        this.district = in.readString();
        this.poiId = in.readString();
        this.poiName = in.readString();
        this.poiAddress = in.readString();
        this.roomNo = in.readString();
        this.tag = in.readString();
        this.longitude = in.readString();
        this.latitude = in.readString();
        this.coordSystem = in.readString();
        this.storeId = in.readString();
        this.isPickup = in.readInt() == 0 ? false : true;
    }

    public static final Parcelable.Creator<MutableAddress> CREATOR = new Parcelable.Creator<MutableAddress>() {
        public MutableAddress createFromParcel(Parcel source) {
            return new MutableAddress(source);
        }

        public MutableAddress[] newArray(int size) {
            return new MutableAddress[size];
        }
    };
}
